package jupiter.filters;

import org.json.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;
import java.util.ArrayList;

import jupiter.message.*;

import jupiter.util.DBConnection;
import jupiter.util.Timey;

import java.net.*;
import java.io.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.naming.InitialContext;
import javax.sql.DataSource;
public class MessageFilter {
	static Logger logger = LoggerFactory.getLogger(MessageFilter.class);
	public void Message(){
		
	}
	public JSONObject create(Message message) throws FilterException{
		logger.warn("Message::Create");
		message.throwIfHasNoFrom();
		//should check filtering and such, but later
		if(!message.isFileSystem() && message.containsBlacklistWords())
			throw new FilterException("{error: 'contains blacklisted words'}");
		message.save();
		message.sendToJabber();
		return message.json;
	}
}
